/*
 /* Project: POPS
 * CS 279, Vanderbilt University
 * by: Igor I. Ges, Michael S. Parrish, Mark E. Sakauye
 *
 *  This program is free software: you can redistribute it and/or modify
 *   it under the terms of the GNU General Public License as published by
 *   the Free Software Foundation, either version 3 of the License, or
 *   (at your option) any later version.
 *
 *   This program is distributed in the hope that it will be useful,
 *   but WITHOUT ANY WARRANTY; without even the implied warranty of
 *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *   GNU General Public License for more details.
 *
 *   You should have received a copy of the GNU General Public License
 *   along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */

package com.popsGUI.java;

import java.awt.Color;
import java.awt.Component;
import java.awt.event.ActionEvent;
import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.HashMap;

import javax.swing.table.TableCellRenderer;

import com.popsDB.java.dto.Customers;
import com.popsDB.java.dto.Items;
import com.popsDB.java.dto.Pricesheetitems;
import com.popsDB.java.dto.Pricesheets;

//import com.popsDB.java.dao.CustomersDao;
//import com.popsDB.java.dao.ItemsDao;
//import com.popsDB.java.dao.OrdereditemsDao;
//import com.popsDB.java.dao.OrdersDao;
//import com.popsDB.java.factory.CustomersDaoFactory;
//import com.popsDB.java.factory.ItemsDaoFactory;
//import com.popsDB.java.factory.OrdereditemsDaoFactory;
//import com.popsDB.java.factory.OrdersDaoFactory;

/**
 *
 * @author  __USER__
 */
public class PriceSheetPanel extends javax.swing.JPanel {

	/** Creates new form PriceSheetPanel */
	public PriceSheetPanel() {
		initComponents();
		notificationDialog = new com.popsGUI.java.notificationDialog(null,false);
	}

	//GEN-BEGIN:initComponents
	// <editor-fold defaultstate="collapsed" desc="Generated Code">
	private void initComponents() {

		psp_CreateTemplate_dialog = new javax.swing.JDialog();
		psp_ct_dialogname_label = new javax.swing.JLabel();
		psp_ct_name_label = new javax.swing.JLabel();
		psp_ct_error_label = new javax.swing.JLabel();
		psp_ct_Save_button = new javax.swing.JButton();
		psp_ct_NameField_field = new javax.swing.JTextField();
		psp_CreatePriceSheet_dialog = new javax.swing.JDialog();
		psp_cps_dialogname_label = new javax.swing.JLabel();
		psp_cps_name_label = new javax.swing.JLabel();
		psp_cps_NameField_field = new javax.swing.JTextField();
		psp_cps_pst_name = new javax.swing.JLabel();
		psp_cps_Save_button = new javax.swing.JButton();
		psp_cps_selectPST_combobox = new javax.swing.JComboBox();
		psp_cps_usePSForTemplate_checkbox = new javax.swing.JCheckBox();
		psp_cps_ps_name = new javax.swing.JLabel();
		psp_cps_selectPS_combobox = new javax.swing.JComboBox();
		psp_cps_error_label = new javax.swing.JLabel();
		psp_confirmPSTsave_dialog = new javax.swing.JDialog();
		psp_cpsts_Processing_label = new javax.swing.JLabel();
		psp_cpsts_progressbar = new javax.swing.JProgressBar();
		psp_cpsts_discard_button = new javax.swing.JButton();
		psp_cpsts_confirmAll_button = new javax.swing.JButton();
		psp_cpsts_scrollPane = new javax.swing.JScrollPane();
		psp_cpsts_changes_label = new javax.swing.JTextArea();
		psp_confirmPSsave_dialog = new javax.swing.JDialog();
		psp_cpss_Processing_label = new javax.swing.JLabel();
		psp_cpss_progressbar = new javax.swing.JProgressBar();
		psp_cpss_discard_button = new javax.swing.JButton();
		psp_cpss_confirmAll_button = new javax.swing.JButton();
		psp_cpss_confirmModifications_button = new javax.swing.JButton();
		psp_cpss_confirmAdditions_button = new javax.swing.JButton();
		psp_cpss_scrollpane = new javax.swing.JScrollPane();
		psp_cpss_changes_label = new javax.swing.JTextArea();
		psp_foundCustomers_dialog = new javax.swing.JDialog();
		psp_fc_serviceText_label = new javax.swing.JLabel();
		psp_fc_tempalteInfo_label = new javax.swing.JLabel();
		psp_fc_serviceText2_label = new javax.swing.JLabel();
		jScrollPane2 = new javax.swing.JScrollPane();
		psp_fc_customerNames_textArea = new javax.swing.JTextArea();
		psp_fc_close_button = new javax.swing.JButton();
		psp_priceSheetTemplate_combobox = new javax.swing.JComboBox();
		psp_priceSheet_combobox = new javax.swing.JComboBox();
		psp_showChanges_checkbox = new javax.swing.JCheckBox();
		psp_priceSheet_label = new javax.swing.JLabel();
		psp_priceSheetTemplace_label = new javax.swing.JLabel();
		jScrollPane1 = new javax.swing.JScrollPane();
		psp_itemList_table = new javax.swing.JTable();
		psp_createPriceSheet_button = new javax.swing.JButton();
		psp_createTemplate_button = new javax.swing.JButton();
		psp_save_button = new javax.swing.JButton();
		psp_error_label = new javax.swing.JLabel();
		psp_PST_numofID_label = new javax.swing.JLabel();
		psp_PS_numofID_label = new javax.swing.JLabel();
		psp_CUST_numofID_label = new javax.swing.JLabel();
		psp_PST_ID_label = new javax.swing.JLabel();
		psp_PS_ID_label = new javax.swing.JLabel();
		psp_ShowPSTChildren_button = new javax.swing.JButton();
		psp_showPSTCustomers_button = new javax.swing.JButton();
		psp_DeletePST_button = new javax.swing.JButton();
		psp_showPSCustomers_button = new javax.swing.JButton();
		psp_DeletePS_button = new javax.swing.JButton();
		psp_showPSchildren_button = new javax.swing.JButton();

		psp_CreateTemplate_dialog.setBackground(java.awt.Color.white);
		psp_CreateTemplate_dialog.setMinimumSize(new java.awt.Dimension(400,
				300));
		psp_CreateTemplate_dialog.setResizable(false);

		psp_ct_dialogname_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		psp_ct_dialogname_label.setText("Create Price Sheet Template");

		psp_ct_name_label.setText("Name:");

		psp_ct_Save_button.setText("Save");
		psp_ct_Save_button.setActionCommand("jButton1");
		psp_ct_Save_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_ct_Save_buttonActionPerformed(evt);
					}
				});

		javax.swing.GroupLayout psp_CreateTemplate_dialogLayout = new javax.swing.GroupLayout(
				psp_CreateTemplate_dialog.getContentPane());
		psp_CreateTemplate_dialog.getContentPane().setLayout(
				psp_CreateTemplate_dialogLayout);
		psp_CreateTemplate_dialogLayout
				.setHorizontalGroup(psp_CreateTemplate_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								psp_CreateTemplate_dialogLayout
										.createSequentialGroup()
										.addGroup(
												psp_CreateTemplate_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																psp_CreateTemplate_dialogLayout
																		.createSequentialGroup()
																		.addGap(
																				42,
																				42,
																				42)
																		.addGroup(
																				psp_CreateTemplate_dialogLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING,
																								false)
																						.addComponent(
																								psp_ct_error_label,
																								javax.swing.GroupLayout.PREFERRED_SIZE,
																								301,
																								javax.swing.GroupLayout.PREFERRED_SIZE)
																						.addGroup(
																								psp_CreateTemplate_dialogLayout
																										.createSequentialGroup()
																										.addComponent(
																												psp_ct_name_label)
																										.addGap(
																												18,
																												18,
																												18)
																										.addComponent(
																												psp_ct_NameField_field))))
														.addGroup(
																psp_CreateTemplate_dialogLayout
																		.createSequentialGroup()
																		.addGap(
																				168,
																				168,
																				168)
																		.addComponent(
																				psp_ct_Save_button))
														.addGroup(
																javax.swing.GroupLayout.Alignment.TRAILING,
																psp_CreateTemplate_dialogLayout
																		.createSequentialGroup()
																		.addContainerGap()
																		.addComponent(
																				psp_ct_dialogname_label,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				376,
																				Short.MAX_VALUE)))
										.addContainerGap()));
		psp_CreateTemplate_dialogLayout
				.setVerticalGroup(psp_CreateTemplate_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								psp_CreateTemplate_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												psp_ct_dialogname_label,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												35,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addGap(28, 28, 28)
										.addGroup(
												psp_CreateTemplate_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addComponent(
																psp_ct_name_label)
														.addComponent(
																psp_ct_NameField_field,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												33, Short.MAX_VALUE)
										.addComponent(psp_ct_Save_button)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												psp_ct_error_label,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												50,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addGap(45, 45, 45)));

		psp_CreatePriceSheet_dialog.setEnabled(false);
		psp_CreatePriceSheet_dialog.setMinimumSize(new java.awt.Dimension(400,
				320));

		psp_cps_dialogname_label
				.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
		psp_cps_dialogname_label.setText("Create Price Sheet");

		psp_cps_name_label.setText("Name:");

		psp_cps_pst_name.setText("Price Sheet Template:");

		psp_cps_Save_button.setText("Save");
		psp_cps_Save_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_cps_Save_buttonActionPerformed(evt);
					}
				});

		psp_cps_usePSForTemplate_checkbox
				.setText("Use Price Sheet as template instead");
		psp_cps_usePSForTemplate_checkbox
				.setToolTipText("When you select this checkbox you can select a PriceSheet on which to base your new PriceSheet. You can select different PriceSheets by changing the PriceSheetTemplate selected above.");
		psp_cps_usePSForTemplate_checkbox
				.addItemListener(new java.awt.event.ItemListener() {
					public void itemStateChanged(java.awt.event.ItemEvent evt) {
						psp_cps_usePSForTemplate_checkboxItemStateChanged(evt);
					}
				});
		psp_cps_usePSForTemplate_checkbox
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_cps_usePSForTemplate_checkboxActionPerformed(evt);
					}
				});

		psp_cps_ps_name.setText("Price Sheet:");

		javax.swing.GroupLayout psp_CreatePriceSheet_dialogLayout = new javax.swing.GroupLayout(
				psp_CreatePriceSheet_dialog.getContentPane());
		psp_CreatePriceSheet_dialog.getContentPane().setLayout(
				psp_CreatePriceSheet_dialogLayout);
		psp_CreatePriceSheet_dialogLayout
				.setHorizontalGroup(psp_CreatePriceSheet_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								psp_CreatePriceSheet_dialogLayout
										.createSequentialGroup().addGap(166,
												166, 166).addComponent(
												psp_cps_Save_button)
										.addContainerGap(177, Short.MAX_VALUE))
						.addGroup(
								psp_CreatePriceSheet_dialogLayout
										.createSequentialGroup()
										.addGap(30, 30, 30)
										.addComponent(
												psp_cps_error_label,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												358, Short.MAX_VALUE)
										.addContainerGap())
						.addGroup(
								psp_CreatePriceSheet_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												psp_CreatePriceSheet_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(
																psp_cps_usePSForTemplate_checkbox,
																javax.swing.GroupLayout.Alignment.TRAILING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																376,
																Short.MAX_VALUE)
														.addComponent(
																psp_cps_dialogname_label,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																376,
																Short.MAX_VALUE)
														.addGroup(
																psp_CreatePriceSheet_dialogLayout
																		.createSequentialGroup()
																		.addGap(
																				10,
																				10,
																				10)
																		.addGroup(
																				psp_CreatePriceSheet_dialogLayout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addGroup(
																								psp_CreatePriceSheet_dialogLayout
																										.createSequentialGroup()
																										.addComponent(
																												psp_cps_pst_name)
																										.addGap(
																												18,
																												18,
																												18)
																										.addComponent(
																												psp_cps_selectPST_combobox,
																												0,
																												234,
																												Short.MAX_VALUE))
																						.addGroup(
																								psp_CreatePriceSheet_dialogLayout
																										.createSequentialGroup()
																										.addComponent(
																												psp_cps_name_label)
																										.addGap(
																												18,
																												18,
																												18)
																										.addComponent(
																												psp_cps_NameField_field,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												313,
																												Short.MAX_VALUE))
																						.addGroup(
																								psp_CreatePriceSheet_dialogLayout
																										.createSequentialGroup()
																										.addComponent(
																												psp_cps_ps_name)
																										.addGap(
																												71,
																												71,
																												71)
																										.addComponent(
																												psp_cps_selectPS_combobox,
																												0,
																												234,
																												Short.MAX_VALUE)))))
										.addContainerGap()));
		psp_CreatePriceSheet_dialogLayout
				.setVerticalGroup(psp_CreatePriceSheet_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								psp_CreatePriceSheet_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												psp_cps_dialogname_label,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												39,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												psp_CreatePriceSheet_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																psp_cps_name_label)
														.addComponent(
																psp_cps_NameField_field,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addGap(18, 18, 18)
										.addGroup(
												psp_CreatePriceSheet_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																psp_cps_pst_name)
														.addComponent(
																psp_cps_selectPST_combobox,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addGap(18, 18, 18)
										.addComponent(
												psp_cps_usePSForTemplate_checkbox)
										.addGap(18, 18, 18)
										.addGroup(
												psp_CreatePriceSheet_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																psp_cps_ps_name)
														.addComponent(
																psp_cps_selectPS_combobox,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
										.addComponent(
												psp_cps_error_label,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												21,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(psp_cps_Save_button)
										.addContainerGap(30, Short.MAX_VALUE)));

		psp_confirmPSTsave_dialog.setMinimumSize(new java.awt.Dimension(450,
				540));

		psp_cpsts_Processing_label.setText("Processing...");

		psp_cpsts_discard_button.setText("Discard");
		psp_cpsts_discard_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_cpsts_discard_buttonActionPerformed(evt);
					}
				});

		psp_cpsts_confirmAll_button.setText("Confirm Modifications");
		psp_cpsts_confirmAll_button
				.setToolTipText("Saves the modifications of the items lsited above into the database");
		psp_cpsts_confirmAll_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_cpsts_confirmAll_buttonActionPerformed(evt);
					}
				});

		psp_cpsts_changes_label.setColumns(20);
		psp_cpsts_changes_label.setRows(5);
		psp_cpsts_scrollPane.setViewportView(psp_cpsts_changes_label);

		javax.swing.GroupLayout psp_confirmPSTsave_dialogLayout = new javax.swing.GroupLayout(
				psp_confirmPSTsave_dialog.getContentPane());
		psp_confirmPSTsave_dialog.getContentPane().setLayout(
				psp_confirmPSTsave_dialogLayout);
		psp_confirmPSTsave_dialogLayout
				.setHorizontalGroup(psp_confirmPSTsave_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								psp_confirmPSTsave_dialogLayout
										.createSequentialGroup()
										.addGroup(
												psp_confirmPSTsave_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																psp_confirmPSTsave_dialogLayout
																		.createSequentialGroup()
																		.addGap(
																				180,
																				180,
																				180)
																		.addComponent(
																				psp_cpsts_Processing_label,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				75,
																				javax.swing.GroupLayout.PREFERRED_SIZE))
														.addGroup(
																psp_confirmPSTsave_dialogLayout
																		.createSequentialGroup()
																		.addGap(
																				117,
																				117,
																				117)
																		.addComponent(
																				psp_cpsts_progressbar,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				257,
																				javax.swing.GroupLayout.PREFERRED_SIZE))
														.addGroup(
																psp_confirmPSTsave_dialogLayout
																		.createSequentialGroup()
																		.addContainerGap()
																		.addComponent(
																				psp_cpsts_discard_button)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED,
																				202,
																				Short.MAX_VALUE)
																		.addComponent(
																				psp_cpsts_confirmAll_button))
														.addGroup(
																psp_confirmPSTsave_dialogLayout
																		.createSequentialGroup()
																		.addGap(
																				51,
																				51,
																				51)
																		.addComponent(
																				psp_cpsts_scrollPane,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				352,
																				javax.swing.GroupLayout.PREFERRED_SIZE)))
										.addContainerGap()));
		psp_confirmPSTsave_dialogLayout
				.setVerticalGroup(psp_confirmPSTsave_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								psp_confirmPSTsave_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(
												psp_cpsts_Processing_label)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												psp_cpsts_progressbar,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
										.addComponent(
												psp_cpsts_scrollPane,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												408,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												31, Short.MAX_VALUE)
										.addGroup(
												psp_confirmPSTsave_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																psp_cpsts_confirmAll_button)
														.addComponent(
																psp_cpsts_discard_button))
										.addContainerGap()));

		psp_confirmPSsave_dialog
				.setMinimumSize(new java.awt.Dimension(490, 570));

		psp_cpss_Processing_label.setText("Processing...");

		psp_cpss_discard_button.setText("Discard");
		psp_cpss_discard_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_cpss_discard_buttonActionPerformed(evt);
					}
				});

		psp_cpss_confirmAll_button.setText("Confirm All");
		psp_cpss_confirmAll_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_cpss_confirmAll_buttonActionPerformed(evt);
					}
				});

		psp_cpss_confirmModifications_button.setText("Confirm modifications");
		psp_cpss_confirmModifications_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_cpss_confirmModifications_buttonActionPerformed(evt);
					}
				});

		psp_cpss_confirmAdditions_button.setText("Confirm additions");
		psp_cpss_confirmAdditions_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_cpss_confirmAdditions_buttonActionPerformed(evt);
					}
				});

		psp_cpss_changes_label.setColumns(20);
		psp_cpss_changes_label.setRows(5);
		psp_cpss_scrollpane.setViewportView(psp_cpss_changes_label);

		javax.swing.GroupLayout psp_confirmPSsave_dialogLayout = new javax.swing.GroupLayout(
				psp_confirmPSsave_dialog.getContentPane());
		psp_confirmPSsave_dialog.getContentPane().setLayout(
				psp_confirmPSsave_dialogLayout);
		psp_confirmPSsave_dialogLayout
				.setHorizontalGroup(psp_confirmPSsave_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								psp_confirmPSsave_dialogLayout
										.createSequentialGroup()
										.addGap(27, 27, 27)
										.addGroup(
												psp_confirmPSsave_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(
																psp_cpss_scrollpane,
																javax.swing.GroupLayout.Alignment.TRAILING,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																467,
																Short.MAX_VALUE)
														.addGroup(
																psp_confirmPSsave_dialogLayout
																		.createSequentialGroup()
																		.addComponent(
																				psp_cpss_discard_button)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				psp_cpss_confirmModifications_button)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				psp_cpss_confirmAdditions_button)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																		.addComponent(
																				psp_cpss_confirmAll_button)))
										.addContainerGap())
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								psp_confirmPSsave_dialogLayout
										.createSequentialGroup()
										.addContainerGap(231, Short.MAX_VALUE)
										.addComponent(
												psp_cpss_Processing_label,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												75,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addGap(200, 200, 200))
						.addGroup(
								javax.swing.GroupLayout.Alignment.TRAILING,
								psp_confirmPSsave_dialogLayout
										.createSequentialGroup()
										.addContainerGap(149, Short.MAX_VALUE)
										.addComponent(
												psp_cpss_progressbar,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												257,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addGap(100, 100, 100)));
		psp_confirmPSsave_dialogLayout
				.setVerticalGroup(psp_confirmPSsave_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								psp_confirmPSsave_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addComponent(psp_cpss_Processing_label)
										.addGap(12, 12, 12)
										.addComponent(
												psp_cpss_progressbar,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
										.addComponent(
												psp_cpss_scrollpane,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												430,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
												34, Short.MAX_VALUE)
										.addGroup(
												psp_confirmPSsave_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																psp_cpss_discard_button)
														.addComponent(
																psp_cpss_confirmModifications_button)
														.addComponent(
																psp_cpss_confirmAdditions_button)
														.addComponent(
																psp_cpss_confirmAll_button))
										.addContainerGap()));

		psp_fc_serviceText_label.setText("Pricesheet");

		psp_fc_serviceText2_label
				.setText("Customers that use this pricesheet are:");

		psp_fc_customerNames_textArea.setColumns(20);
		psp_fc_customerNames_textArea.setRows(5);
		jScrollPane2.setViewportView(psp_fc_customerNames_textArea);

		psp_fc_close_button.setText("Close");
		psp_fc_close_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_fc_close_buttonActionPerformed(evt);
					}
				});

		javax.swing.GroupLayout psp_foundCustomers_dialogLayout = new javax.swing.GroupLayout(
				psp_foundCustomers_dialog.getContentPane());
		psp_foundCustomers_dialog.getContentPane().setLayout(
				psp_foundCustomers_dialogLayout);
		psp_foundCustomers_dialogLayout
				.setHorizontalGroup(psp_foundCustomers_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								psp_foundCustomers_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												psp_foundCustomers_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addGroup(
																psp_foundCustomers_dialogLayout
																		.createSequentialGroup()
																		.addComponent(
																				psp_fc_serviceText2_label,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				javax.swing.GroupLayout.DEFAULT_SIZE,
																				Short.MAX_VALUE)
																		.addGap(
																				185,
																				185,
																				185))
														.addGroup(
																psp_foundCustomers_dialogLayout
																		.createSequentialGroup()
																		.addComponent(
																				psp_fc_serviceText_label)
																		.addGap(
																				18,
																				18,
																				18)
																		.addComponent(
																				psp_fc_tempalteInfo_label,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				215,
																				javax.swing.GroupLayout.PREFERRED_SIZE))
														.addGroup(
																psp_foundCustomers_dialogLayout
																		.createSequentialGroup()
																		.addComponent(
																				jScrollPane2,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				361,
																				javax.swing.GroupLayout.PREFERRED_SIZE)
																		.addContainerGap())))
						.addGroup(
								psp_foundCustomers_dialogLayout
										.createSequentialGroup().addGap(168,
												168, 168).addComponent(
												psp_fc_close_button)
										.addContainerGap(171, Short.MAX_VALUE)));
		psp_foundCustomers_dialogLayout
				.setVerticalGroup(psp_foundCustomers_dialogLayout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								psp_foundCustomers_dialogLayout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												psp_foundCustomers_dialogLayout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addComponent(
																psp_fc_serviceText_label)
														.addComponent(
																psp_fc_tempalteInfo_label,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																20,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(psp_fc_serviceText2_label)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												jScrollPane2,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												285,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(psp_fc_close_button)
										.addContainerGap(23, Short.MAX_VALUE)));

		setPreferredSize(new java.awt.Dimension(1024, 679));

		psp_priceSheetTemplate_combobox
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_priceSheetTemplate_comboboxActionPerformed(evt);
					}
				});

		psp_priceSheet_combobox
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_priceSheet_comboboxActionPerformed(evt);
					}
				});

		psp_showChanges_checkbox.setText("Only Show Changes");
		psp_showChanges_checkbox
				.addItemListener(new java.awt.event.ItemListener() {
					public void itemStateChanged(java.awt.event.ItemEvent evt) {
						psp_showChanges_checkboxItemStateChanged(evt);
					}
				});

		psp_priceSheet_label.setText("Price Sheet");

		psp_priceSheetTemplace_label.setText("Price Sheet Template");

		psp_itemList_table.setModel(new javax.swing.table.DefaultTableModel(
				new Object[][] { { null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null },
						{ null, null, null, null, null, null, null } },
				new String[] { "Item ID", "Name", "Description", "Unit 1",
						"Price 1", "Unit 2", "Price 2" }) {
			Class[] types = new Class[] { java.lang.Integer.class,
					java.lang.String.class, java.lang.String.class,
					java.lang.String.class, java.lang.Float.class,
					java.lang.String.class, java.lang.Float.class };
			boolean[] canEdit = new boolean[] { false, false, false, false,
					true, false, true };

			public Class getColumnClass(int columnIndex) {
				return types[columnIndex];
			}

			public boolean isCellEditable(int rowIndex, int columnIndex) {
				return canEdit[columnIndex];
			}
		});
		jScrollPane1.setViewportView(psp_itemList_table);

		psp_createPriceSheet_button.setText("Create Price Sheet");
		psp_createPriceSheet_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_createPriceSheet_buttonActionPerformed(evt);
					}
				});

		psp_createTemplate_button.setText("Create Template");
		psp_createTemplate_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_createTemplate_buttonActionPerformed(evt);
					}
				});

		psp_save_button.setText("Save");
		psp_save_button.addActionListener(new java.awt.event.ActionListener() {
			public void actionPerformed(java.awt.event.ActionEvent evt) {
				psp_save_buttonActionPerformed(evt);
			}
		});

		psp_PST_numofID_label.setText("ID:");

		psp_PS_numofID_label.setText("ID:");

		psp_PST_ID_label
				.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
		psp_PST_ID_label.setMaximumSize(new java.awt.Dimension(37, 16));
		psp_PST_ID_label.setMinimumSize(new java.awt.Dimension(37, 16));

		psp_PS_ID_label
				.setHorizontalTextPosition(javax.swing.SwingConstants.LEFT);
		psp_PS_ID_label.setMaximumSize(new java.awt.Dimension(37, 16));
		psp_PS_ID_label.setMinimumSize(new java.awt.Dimension(37, 16));

		psp_ShowPSTChildren_button.setText("Show related PriceSheets");
		psp_ShowPSTChildren_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_ShowPSTChildren_buttonActionPerformed(evt);
					}
				});

		psp_showPSTCustomers_button.setText("Show customers");
		psp_showPSTCustomers_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_showPSTCustomers_buttonActionPerformed(evt);
					}
				});

		psp_DeletePST_button.setText("Delete ");
		psp_DeletePST_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_DeletePST_buttonActionPerformed(evt);
					}
				});

		psp_showPSCustomers_button.setText("Show customers");
		psp_showPSCustomers_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_showPSCustomers_buttonActionPerformed(evt);
					}
				});

		psp_DeletePS_button.setText("Delete ");
		psp_DeletePS_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_DeletePS_buttonActionPerformed(evt);
					}
				});

		psp_showPSchildren_button.setText("Show related PriceSheets");
		psp_showPSchildren_button
				.addActionListener(new java.awt.event.ActionListener() {
					public void actionPerformed(java.awt.event.ActionEvent evt) {
						psp_showPSchildren_buttonActionPerformed(evt);
					}
				});

		javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
		this.setLayout(layout);
		layout
				.setHorizontalGroup(layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								layout
										.createSequentialGroup()
										.addContainerGap()
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.LEADING)
														.addComponent(
																psp_error_label,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																1000,
																Short.MAX_VALUE)
														.addGroup(
																layout
																		.createSequentialGroup()
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addGroup(
																								layout
																										.createSequentialGroup()
																										.addGroup(
																												layout
																														.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.LEADING)
																														.addComponent(
																																psp_priceSheetTemplate_combobox,
																																javax.swing.GroupLayout.PREFERRED_SIZE,
																																242,
																																javax.swing.GroupLayout.PREFERRED_SIZE)
																														.addGroup(
																																layout
																																		.createSequentialGroup()
																																		.addComponent(
																																				psp_priceSheetTemplace_label)
																																		.addGap(
																																				18,
																																				18,
																																				18)
																																		.addComponent(
																																				psp_PST_numofID_label)
																																		.addPreferredGap(
																																				javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
																																		.addComponent(
																																				psp_PST_ID_label,
																																				javax.swing.GroupLayout.DEFAULT_SIZE,
																																				273,
																																				Short.MAX_VALUE)))
																										.addGap(
																												81,
																												81,
																												81))
																						.addGroup(
																								layout
																										.createSequentialGroup()
																										.addComponent(
																												psp_ShowPSTChildren_button)
																										.addPreferredGap(
																												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																										.addComponent(
																												psp_showPSTCustomers_button)
																										.addPreferredGap(
																												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																										.addComponent(
																												psp_DeletePST_button,
																												javax.swing.GroupLayout.PREFERRED_SIZE,
																												107,
																												javax.swing.GroupLayout.PREFERRED_SIZE)
																										.addGap(
																												51,
																												51,
																												51)))
																		.addGroup(
																				layout
																						.createParallelGroup(
																								javax.swing.GroupLayout.Alignment.LEADING)
																						.addGroup(
																								layout
																										.createSequentialGroup()
																										.addGroup(
																												layout
																														.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.LEADING,
																																false)
																														.addGroup(
																																layout
																																		.createSequentialGroup()
																																		.addComponent(
																																				psp_priceSheet_label)
																																		.addPreferredGap(
																																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																																		.addComponent(
																																				psp_PS_numofID_label)
																																		.addPreferredGap(
																																				javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																																		.addComponent(
																																				psp_PS_ID_label,
																																				javax.swing.GroupLayout.PREFERRED_SIZE,
																																				56,
																																				javax.swing.GroupLayout.PREFERRED_SIZE))
																														.addComponent(
																																psp_priceSheet_combobox,
																																javax.swing.GroupLayout.PREFERRED_SIZE,
																																176,
																																javax.swing.GroupLayout.PREFERRED_SIZE))
																										.addPreferredGap(
																												javax.swing.LayoutStyle.ComponentPlacement.RELATED,
																												184,
																												Short.MAX_VALUE)
																										.addGroup(
																												layout
																														.createParallelGroup(
																																javax.swing.GroupLayout.Alignment.TRAILING)
																														.addComponent(
																																psp_CUST_numofID_label)
																														.addComponent(
																																psp_showChanges_checkbox)))
																						.addGroup(
																								javax.swing.GroupLayout.Alignment.TRAILING,
																								layout
																										.createSequentialGroup()
																										.addComponent(
																												psp_showPSchildren_button,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												javax.swing.GroupLayout.DEFAULT_SIZE,
																												Short.MAX_VALUE)
																										.addPreferredGap(
																												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																										.addComponent(
																												psp_showPSCustomers_button)
																										.addPreferredGap(
																												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
																										.addComponent(
																												psp_DeletePS_button,
																												javax.swing.GroupLayout.PREFERRED_SIZE,
																												107,
																												javax.swing.GroupLayout.PREFERRED_SIZE)
																										.addGap(
																												88,
																												88,
																												88))))
														.addGroup(
																javax.swing.GroupLayout.Alignment.TRAILING,
																layout
																		.createSequentialGroup()
																		.addComponent(
																				psp_createTemplate_button)
																		.addPreferredGap(
																				javax.swing.LayoutStyle.ComponentPlacement.RELATED,
																				394,
																				Short.MAX_VALUE)
																		.addComponent(
																				psp_createPriceSheet_button)
																		.addGap(
																				303,
																				303,
																				303)
																		.addComponent(
																				psp_save_button))
														.addComponent(
																jScrollPane1,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																1000,
																Short.MAX_VALUE))
										.addContainerGap()));
		layout
				.setVerticalGroup(layout
						.createParallelGroup(
								javax.swing.GroupLayout.Alignment.LEADING)
						.addGroup(
								layout
										.createSequentialGroup()
										.addGap(27, 27, 27)
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.TRAILING)
														.addGroup(
																layout
																		.createParallelGroup(
																				javax.swing.GroupLayout.Alignment.BASELINE)
																		.addComponent(
																				psp_priceSheetTemplace_label)
																		.addComponent(
																				psp_PST_numofID_label,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				16,
																				javax.swing.GroupLayout.PREFERRED_SIZE)
																		.addComponent(
																				psp_CUST_numofID_label,
																				javax.swing.GroupLayout.PREFERRED_SIZE,
																				16,
																				javax.swing.GroupLayout.PREFERRED_SIZE))
														.addComponent(
																psp_PST_ID_label,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																16,
																javax.swing.GroupLayout.PREFERRED_SIZE)
														.addComponent(
																psp_PS_ID_label,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																16,
																javax.swing.GroupLayout.PREFERRED_SIZE)
														.addComponent(
																psp_priceSheet_label)
														.addComponent(
																psp_PS_numofID_label,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																16,
																javax.swing.GroupLayout.PREFERRED_SIZE))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																psp_priceSheetTemplate_combobox,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE)
														.addComponent(
																psp_priceSheet_combobox,
																javax.swing.GroupLayout.PREFERRED_SIZE,
																javax.swing.GroupLayout.DEFAULT_SIZE,
																javax.swing.GroupLayout.PREFERRED_SIZE)
														.addComponent(
																psp_showChanges_checkbox))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																psp_ShowPSTChildren_button)
														.addComponent(
																psp_showPSTCustomers_button)
														.addComponent(
																psp_DeletePST_button)
														.addComponent(
																psp_DeletePS_button)
														.addComponent(
																psp_showPSCustomers_button)
														.addComponent(
																psp_showPSchildren_button))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												jScrollPane1,
												javax.swing.GroupLayout.PREFERRED_SIZE,
												458,
												javax.swing.GroupLayout.PREFERRED_SIZE)
										.addGap(45, 45, 45)
										.addGroup(
												layout
														.createParallelGroup(
																javax.swing.GroupLayout.Alignment.BASELINE)
														.addComponent(
																psp_save_button)
														.addComponent(
																psp_createTemplate_button)
														.addComponent(
																psp_createPriceSheet_button))
										.addPreferredGap(
												javax.swing.LayoutStyle.ComponentPlacement.RELATED)
										.addComponent(
												psp_error_label,
												javax.swing.GroupLayout.DEFAULT_SIZE,
												20, Short.MAX_VALUE)
										.addContainerGap()));
	}// </editor-fold>
	//GEN-END:initComponents

	private void psp_showChanges_checkboxItemStateChanged(
			java.awt.event.ItemEvent evt) {
		ActionEvent _evt = null;
		this.psp_priceSheet_comboboxActionPerformed(_evt);
	}

	private void psp_cps_usePSForTemplate_checkboxActionPerformed(
			java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
	}

	private void psp_showPSCustomers_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		int PSid = MEDIATOR.getPSid((String) this.psp_priceSheet_combobox
				.getSelectedItem());

		//check if a valid one is selected
		if (PSid == -1) { //check for errors
			notificationDialog.displayNotification("ERROR: Invalid Selection");
		} else {
			//get it's children
			Customers[] _cust = MEDIATOR
					.getAllCustomersThatUseThisPriceSheet(PSid);
			if (_cust.length == 0) {//bug # 110 original: _cust == null
				notificationDialog
						.displayNotification("This PriceSheet has no Customers");
			}
			//display children in notification window
			else {
				notificationDialog
						.displayNotification("This Pricesheet has the following Customers:"
								+ this.TurnCustomerListIntoHTML(_cust));
			}

		}
	}

	private void psp_showPSTCustomers_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		int PSid = MEDIATOR
				.getPSid((String) this.psp_priceSheetTemplate_combobox
						.getSelectedItem());

		//check if a valid one is selected
		if (PSid == -1) { //check for errors
			notificationDialog.displayNotification("ERROR: Invalid Selection");
		} else {
			//get it's children
			Customers[] _cust = MEDIATOR
					.getAllCustomersThatUseThisPriceSheet(PSid);
			if (_cust.length == 0) {//bug # 110 original: _cust == null
				notificationDialog
						.displayNotification("This PriceSheet has no Customers");
			}
			//display children in notification window
			else {
				notificationDialog
						.displayNotification("This Pricesheet has the following Customers:"
								+ this.TurnCustomerListIntoHTML(_cust));
			}

		}
	}

	private void psp_showPSchildren_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		// get the pricesheet
		int PSid = MEDIATOR.getPSid((String) this.psp_priceSheet_combobox
				.getSelectedItem());

		//check if a valid one is selected
		if (PSid == -1) { //check for errors
			notificationDialog.displayNotification("ERROR: Invalid Selection");
		} else {
			//get it's children
			Pricesheets[] _ps = MEDIATOR.getAllChildrenOfPST(PSid);
			if (_ps.length == 0) { //bug # 110 original: _ps == null
				notificationDialog
						.displayNotification("This PriceSheet has no decendants");
			}
			//display children in notification window
			else {
				notificationDialog
						.displayNotification("This Pricesheet has the following decendants:"
								+ this.TurnPriceSheetListIntoHTML(_ps));
			}

		}

	}

	private void psp_ShowPSTChildren_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		// get the pricesheet
		int PSid = MEDIATOR
				.getPSid((String) this.psp_priceSheetTemplate_combobox
						.getSelectedItem());

		//check if a valid one is selected
		if (PSid == -1) { //check for errors
			notificationDialog.displayNotification("ERROR: Invalid Selection");
		} else {
			//get it's children
			Pricesheets[] _ps = MEDIATOR.getAllChildrenOfPST(PSid);
			if (_ps.length == 0) { //bug # 110 original: _ps == null
				notificationDialog
						.displayNotification("This PriceSheet has no decendants");
			}
			//display children in notification window
			else {
				notificationDialog
						.displayNotification("This Pricesheet has the following decendants:"
								+ this.TurnPriceSheetListIntoHTML(_ps));
			}

		}

	}

	private void psp_DeletePS_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {

		//get the name
		int PSid = MEDIATOR.getPSid((String) this.psp_priceSheet_combobox
				.getSelectedItem());

		if (PSid == -1) { //check for errors
			notificationDialog.displayNotification("ERROR: Invalid Selection");
		} else {//if all is cool check if it can be deleted
			Customers[] _cust = MEDIATOR
					.getAllCustomersThatUseThisPriceSheet(PSid);

			Pricesheets[] _ps = MEDIATOR.getAllChildrenOfPST(PSid);

			boolean found_errors = false;
			String output = "PriceSheet can't be deleted due to unresolved dependencies.";
			if (_cust != null) {
				found_errors = true;
				output += " <br />  The following customers need to be assigned a different PriceSheet:";
				output += this.TurnCustomerListIntoHTML(_cust);
			}
			if (_ps != null) {
				found_errors = true;
				output += " <br />  The following PriceSheets need to be deleted before this PriceSheet: ";
				output += this.TurnPriceSheetListIntoHTML(_ps);
			}

			//now either delete or explain why not
			if (found_errors) {
				notificationDialog.displayNotification(output);
			} else {
				MEDIATOR.deletPriceSheet(PSid);
			}
		}
	}

	private void psp_DeletePST_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {

		//get the name
		int PSid = MEDIATOR
				.getPSid((String) this.psp_priceSheetTemplate_combobox
						.getSelectedItem());

		if (PSid == -1) { //check for errors
			notificationDialog.displayNotification("ERROR: Invalid Selection");
		} else {//if all is cool check if it can be deleted
			Customers[] _cust = MEDIATOR
					.getAllCustomersThatUseThisPriceSheetTemplate(PSid);
			Pricesheets[] _ps = MEDIATOR.getAllChildrenOfPST(PSid);

			boolean found_errors = false;
			String output = "PriceSheet can't be deleted due to unresolved dependencies.";
			if (_cust.length != 0) { //bug # 108
				found_errors = true;
				output += " <br />  The following customers need to be assigned a different PriceSheet:";
				output += this.TurnCustomerListIntoHTML(_cust);
			}
			if (_ps.length != 0) { //bug # 108
				found_errors = true;
				output += " <br />  The following PriceSheets need to be deleted before this PriceSheet: ";
				output += this.TurnPriceSheetListIntoHTML(_ps);
			}

			//now either delete or explain why not
			if (found_errors) {
				notificationDialog.displayNotification(output);
			} else {
				MEDIATOR.deletPriceSheet(PSid);
				notificationDialog.displayNotification("Pricesheet "
						+ PSid
						+ " : "
						+ this.psp_priceSheetTemplate_combobox
								.getSelectedItem() + " was deleted."); //bug # 108
			}
		}
	}

	private void psp_fc_close_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		setFoundCustomersDialogEnabledParamenterTo(false);
	}

	private void psp_cpsts_confirmAll_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		MEDIATOR.savePSmodifications(modQueue);
		modQueue.clear();
		addQueue.clear();
	}

	private void psp_cpss_confirmAll_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		MEDIATOR.savePSadditions(addQueue);
		MEDIATOR.savePSmodifications(modQueue);
		modQueue.clear();
		addQueue.clear();
	}

	private void psp_cpss_confirmAdditions_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		MEDIATOR.savePSadditions(addQueue);
		modQueue.clear();
		addQueue.clear();
	}

	private void psp_cpss_confirmModifications_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		MEDIATOR.savePSmodifications(modQueue);
		modQueue.clear();
		addQueue.clear();
	}

	private void psp_cps_usePSForTemplate_checkboxItemStateChanged(
			java.awt.event.ItemEvent evt) {
		this.psp_cps_error_label.setText("");
		if (this.psp_cps_usePSForTemplate_checkbox.isSelected()) {
			if (this.psp_cps_selectPST_combobox.getSelectedIndex() == -1) {
				this.psp_cps_error_label
						.setText("Please select a Template first");
				this.psp_cps_usePSForTemplate_checkbox.setSelected(false);
			} else {
				this.psp_cps_selectPS_combobox.setEnabled(true);
				this.psp_cps_selectPS_combobox.setVisible(true);
				this.psp_cps_selectPST_combobox.setEditable(false);
				this.psp_cps_ps_name.setVisible(true);
				this.loadCPSPriceSheetComboboxWithChildrenOf(MEDIATOR
						.getPSid((String) this.psp_cps_selectPST_combobox
								.getSelectedItem()));
			}
		} else {
			this.psp_cps_selectPS_combobox.setEnabled(false);
			this.psp_cps_selectPS_combobox.setVisible(false);
			this.psp_cps_selectPST_combobox.setEditable(true);
			this.psp_cps_ps_name.setVisible(false);
		}
	}

	private void psp_cpsts_discard_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		modQueue.clear();
		this.disable_psp_confirmPSTsave_dialog();
	}

	private void psp_cpss_discard_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		modQueue.clear();
		addQueue.clear();
		disable_psp_confirmPSsave_dialog();
	}

	private void psp_save_buttonActionPerformed(java.awt.event.ActionEvent evt) {
		//error check the input

		if (noInputErrorsInTable()) {
			//are we editing a PST
			//or are we editing a PS
			if (this.psp_priceSheet_combobox.getSelectedItem() == null) {//its a PST

				//find changes
				Pricesheetitems[] _pst = MEDIATOR.getPriceSheetItems(MEDIATOR
						.getPSid((String) this.psp_priceSheetTemplate_combobox
								.getSelectedItem()));

				this.findChangesInTable(_pst);

			} else {//its a PS
				//find changes
				int PSid = MEDIATOR
						.getPSid((String) this.psp_priceSheet_combobox
								.getSelectedItem());
				Pricesheetitems[] _ps = MEDIATOR.getPriceSheetItems(PSid);

				ArrayList<Pricesheetitems> _fullPS = MEDIATOR
						.getCompletePricesheetPSIs(PSid);

				this.findChangesInTable(_ps, _fullPS);

			}

		}
	}

	private void psp_priceSheet_comboboxActionPerformed(
			java.awt.event.ActionEvent evt) {

		//////////////////
		//check if empty//
		//////////////////
		if (this.psp_priceSheet_combobox.getSelectedItem() != null) {
			///////////////////
			//try to get PSid//
			///////////////////
			int PSid = MEDIATOR.getPSid((String) this.psp_priceSheet_combobox
					.getSelectedItem());
			if (PSid == -1) {
				System.out
						.println("ERROR!!!!!!!!!!! in psp_priceSheet_comboboxActionPerformed");
			} else {
				//////////////////
				// then display //
				//////////////////

				//if checkbox is checked
				if (this.psp_showChanges_checkbox.isSelected()) {
					this.displayPriceSheetItemListTable(MEDIATOR
							.getPriceSheetItems(PSid));
				} else {//otherwise
					this.displayPriceSheetItemListTableWithFormatting(MEDIATOR
							.getCompletePricesheetPSIs(PSid));
				}

			}
		}

	}

	private void psp_priceSheetTemplate_comboboxActionPerformed(
			java.awt.event.ActionEvent evt) {

		//////////////////
		//check if empty//
		//////////////////
		if (this.psp_priceSheetTemplate_combobox.getSelectedItem() != null) {

			///////////////////
			//try to get PSid//
			///////////////////
			int PSTid = MEDIATOR
					.getPSid((String) this.psp_priceSheetTemplate_combobox
							.getSelectedItem());
			if (PSTid == -1) {
				System.out
						.println("ERROR!!!!!!!!!!! in psp_priceSheetTemplate_comboboxActionPerformed");
			} else {
				//////////////////
				// then display //
				//////////////////

				this.displayPriceSheetItemListTable(MEDIATOR
						.getPriceSheetItems(PSTid));

				this.loadPriceSheetComboboxWithChildrenOf(PSTid);
			}
		} else {
			this.reloadPriceSheetCombobox();
		}

	}

	private void psp_createPriceSheet_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:

		/////////////////////////
		//initialize the dialog//
		/////////////////////////
		this.psp_cps_usePSForTemplate_checkbox.setSelected(false);
		this.setPriceSheetPanelCreatePriceSheetDialogComponentsTo(true);

		//initialize pricesheet combobox
		reloadPSP_comboboxes();

	}

	private void psp_cps_Save_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {
		// TODO add your handling code here:
		this.psp_cps_error_label.setText("");
		//////////////
		//Initialize//
		//////////////
		boolean no_errors = true;
		//boolean create_from_PST_flag = true;
		String name = this.psp_cps_NameField_field.getText();
		String PSTname = (String) this.psp_cps_selectPST_combobox
				.getSelectedItem();

		/////////////////
		//errorchecking//
		/////////////////
		if (name.length() > this.PRICE_SHEET_NAME_LENGTH - 1) {
			no_errors = false;
			this.psp_cps_error_label.setText("ERROR: name is too long/n "
					+ "please keep it under " + this.PRICE_SHEET_NAME_LENGTH
					+ " characters.");
		}

		if (!MEDIATOR.checkPSname(name)) {
			no_errors = false;
			this.psp_cps_error_label
					.setText("ERROR: name already exists. please try another one");
		}

		if (name.length() == 0) {
			no_errors = false;
			this.psp_cps_error_label
					.setText("ERROR: please enter a name for the pricesheet");
		}

		if (PSTname.length() == 0) {
			no_errors = false;
			this.psp_cps_error_label.setText("ERROR: please select a template");
		}

		if (this.psp_cps_usePSForTemplate_checkbox.isSelected()
				&& this.psp_cps_selectPS_combobox.getSelectedIndex() == -1) {
			no_errors = false;
			this.psp_cps_error_label
					.setText("ERROR: please select a pricesheet");
			//	create_from_PST_flag = false;
		}
		////////
		//save//
		////////

		if (no_errors) {
			if (this.psp_cps_usePSForTemplate_checkbox.isSelected()) {
				MEDIATOR.createNewPS(name,
						(String) this.psp_cps_selectPS_combobox
								.getSelectedItem());
			} else {
				MEDIATOR.createNewPS(name, PSTname);
			}
			//clearing up//

			this.setPriceSheetPanelCreatePriceSheetDialogComponentsTo(false); //bug # 114
			this.psp_cps_NameField_field.setText("");
			this.psp_cps_selectPS_combobox.setVisible(false);
			this.psp_cps_ps_name.setVisible(false);
			this.psp_cps_usePSForTemplate_checkbox.setSelected(false);

			//bug # 113
			reloadPriceSheetCombobox();
		}
	}

	private void psp_ct_Save_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {

		//get text
		String name = this.psp_ct_NameField_field.getText();

		///////////////
		//error check//
		///////////////
		boolean no_errors = true;
		if (name.length() > this.PRICE_SHEET_NAME_LENGTH - 1) {
			no_errors = false;
			this.psp_ct_error_label.setText("ERROR: name is too long/n "
					+ "please keep it under " + this.PRICE_SHEET_NAME_LENGTH
					+ " characters.");
		}

		if (!MEDIATOR.checkPSname(name)) {
			no_errors = false;
			this.psp_ct_error_label
					.setText("ERROR: name already exists. please try another one");
		}

		if (name.length() == 0) {
			no_errors = false;
			this.psp_ct_error_label
					.setText("ERROR: please enter a name for the pricesheet");
		}
		//////////////
		//if correct//
		//////////////

		if (no_errors) {
			//save	
			MEDIATOR.createNewPST(name);

			//TODO: update the PST drop-down box

			this.reloadPSP_comboboxes();

			//clean up windows	
			this
					.setPriceSheetPanelCreatePriceSheetTemplateDialogComponentsTo(false);

		}
	}

	//NAME: psp_createTemplate_buttonActionPerformed
	//IN: 	none
	//OUT:	none
	//FUNC:	activates the new window to create a template. 
	//		activates all components of the window
	private void psp_createTemplate_buttonActionPerformed(
			java.awt.event.ActionEvent evt) {

		this.setPriceSheetPanelCreatePriceSheetTemplateDialogComponentsTo(true);
		this.psp_ct_error_label.setText("");
	}

	//GEN-BEGIN:variables
	// Variables declaration - do not modify
	private javax.swing.JScrollPane jScrollPane1;
	private javax.swing.JScrollPane jScrollPane2;
	private javax.swing.JLabel psp_CUST_numofID_label;
	private javax.swing.JDialog psp_CreatePriceSheet_dialog;
	private javax.swing.JDialog psp_CreateTemplate_dialog;
	private javax.swing.JButton psp_DeletePST_button;
	private javax.swing.JButton psp_DeletePS_button;
	private javax.swing.JLabel psp_PST_ID_label;
	private javax.swing.JLabel psp_PST_numofID_label;
	private javax.swing.JLabel psp_PS_ID_label;
	private javax.swing.JLabel psp_PS_numofID_label;
	private javax.swing.JButton psp_ShowPSTChildren_button;
	private javax.swing.JDialog psp_confirmPSTsave_dialog;
	private javax.swing.JDialog psp_confirmPSsave_dialog;
	private javax.swing.JTextField psp_cps_NameField_field;
	private javax.swing.JButton psp_cps_Save_button;
	private javax.swing.JLabel psp_cps_dialogname_label;
	private javax.swing.JLabel psp_cps_error_label;
	private javax.swing.JLabel psp_cps_name_label;
	private javax.swing.JLabel psp_cps_ps_name;
	private javax.swing.JLabel psp_cps_pst_name;
	private javax.swing.JComboBox psp_cps_selectPST_combobox;
	private javax.swing.JComboBox psp_cps_selectPS_combobox;
	private javax.swing.JCheckBox psp_cps_usePSForTemplate_checkbox;
	private javax.swing.JLabel psp_cpss_Processing_label;
	private javax.swing.JTextArea psp_cpss_changes_label;
	private javax.swing.JButton psp_cpss_confirmAdditions_button;
	private javax.swing.JButton psp_cpss_confirmAll_button;
	private javax.swing.JButton psp_cpss_confirmModifications_button;
	private javax.swing.JButton psp_cpss_discard_button;
	private javax.swing.JProgressBar psp_cpss_progressbar;
	private javax.swing.JScrollPane psp_cpss_scrollpane;
	private javax.swing.JLabel psp_cpsts_Processing_label;
	private javax.swing.JTextArea psp_cpsts_changes_label;
	private javax.swing.JButton psp_cpsts_confirmAll_button;
	private javax.swing.JButton psp_cpsts_discard_button;
	private javax.swing.JProgressBar psp_cpsts_progressbar;
	private javax.swing.JScrollPane psp_cpsts_scrollPane;
	private javax.swing.JButton psp_createPriceSheet_button;
	private javax.swing.JButton psp_createTemplate_button;
	private javax.swing.JTextField psp_ct_NameField_field;
	private javax.swing.JButton psp_ct_Save_button;
	private javax.swing.JLabel psp_ct_dialogname_label;
	private javax.swing.JLabel psp_ct_error_label;
	private javax.swing.JLabel psp_ct_name_label;
	private javax.swing.JLabel psp_error_label;
	private javax.swing.JButton psp_fc_close_button;
	private javax.swing.JTextArea psp_fc_customerNames_textArea;
	private javax.swing.JLabel psp_fc_serviceText2_label;
	private javax.swing.JLabel psp_fc_serviceText_label;
	private javax.swing.JLabel psp_fc_tempalteInfo_label;
	private javax.swing.JDialog psp_foundCustomers_dialog;
	private javax.swing.JTable psp_itemList_table;
	private javax.swing.JLabel psp_priceSheetTemplace_label;
	private javax.swing.JComboBox psp_priceSheetTemplate_combobox;
	private javax.swing.JComboBox psp_priceSheet_combobox;
	private javax.swing.JLabel psp_priceSheet_label;
	private javax.swing.JButton psp_save_button;
	private javax.swing.JCheckBox psp_showChanges_checkbox;
	private javax.swing.JButton psp_showPSCustomers_button;
	private javax.swing.JButton psp_showPSTCustomers_button;
	private javax.swing.JButton psp_showPSchildren_button;
	// End of variables declaration//GEN-END:variables
	private com.popsGUI.java.notificationDialog notificationDialog;
	//	private com.popsGUI.java.notificationDialog notificationDialog;

	final int PS_ID_COLUMN = 0;
	final int PS_NAME_COLUMN = 1;
	final int PS_DESCRIPTION_COLUMN = 2;

	final int PS_UNIT1_COLUMN = 3;
	final int PS_UNIT1PRICE_COLUMN = 4;
	final int PS_UNIT2_COLUMN = 5;
	final int PS_UNIT2PRICE_COLUMN = 6;

	final String MARKER = "=>>>";

	////////////////Our variable declarations /////////////////
	//	CustomersDao CustomersDAO = CustomersDaoFactory.create();
	//	ItemsDao ItemsDAO = ItemsDaoFactory.create();
	//	OrdereditemsDao OrdereditemsDAO = OrdereditemsDaoFactory.create();
	//	OrdersDao OrdersDAO = OrdersDaoFactory.create();

	Mediator MEDIATOR = Mediator.getInstance();

	ArrayList<Pricesheetitems> modQueue = new ArrayList<Pricesheetitems>();
	ArrayList<Pricesheetitems> addQueue = new ArrayList<Pricesheetitems>();

	DateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm");
	DecimalFormat decimlPriceFormat = new DecimalFormat("#.##");

	final int PRICE_SHEET_NAME_LENGTH = 24; //db limited

	///////////// End of our variable declarations /////////////

	public void setPriceSheetPanelComponentsEnabledParameterTo(boolean flag) {
		this.setEnabled(flag);
		this.psp_priceSheetTemplate_combobox.setEnabled(flag);
		this.psp_priceSheet_combobox.setEnabled(flag);
		this.psp_createPriceSheet_button.setEnabled(flag);
		this.psp_createTemplate_button.setEnabled(flag);
		this.psp_save_button.setEnabled(flag);

		this.psp_showPSCustomers_button.setEnabled(flag);
		this.psp_ShowPSTChildren_button.setEnabled(flag);
		this.psp_showPSchildren_button.setEnabled(flag);
		this.psp_showPSTCustomers_button.setEnabled(flag);
		this.psp_DeletePS_button.setEnabled(flag);
		this.psp_DeletePST_button.setEnabled(flag);

		this.psp_showPSCustomers_button.setVisible(flag);
		this.psp_ShowPSTChildren_button.setVisible(flag);
		this.psp_showPSchildren_button.setVisible(flag);
		this.psp_showPSTCustomers_button.setVisible(flag);
		this.psp_DeletePS_button.setVisible(flag);
		this.psp_DeletePST_button.setVisible(flag);

		disable_psp_confirmPSsave_dialog();
		disable_psp_confirmPSTsave_dialog();

		this
				.setPriceSheetPanelCreatePriceSheetTemplateDialogComponentsTo(false);

		this.setPriceSheetPanelCreatePriceSheetDialogComponentsTo(false);

		this.setFoundCustomersDialogEnabledParamenterTo(false);
	}

	public void disable_psp_confirmPSsave_dialog() {
		this.psp_cpss_progressbar.setEnabled(false);
		this.psp_cpss_Processing_label.setEnabled(false);
		this.psp_cpss_progressbar.setVisible(false);
		this.psp_cpss_Processing_label.setVisible(false);
		this.psp_cpss_confirmAdditions_button.setVisible(false);
		this.psp_cpss_confirmModifications_button.setEnabled(false);
		this.psp_cpss_confirmAdditions_button.setVisible(false);
		this.psp_cpss_confirmModifications_button.setEnabled(false);
		this.psp_cpss_confirmAll_button.setEnabled(false);
		this.psp_cpss_discard_button.setEnabled(false);
		this.psp_cpss_confirmAll_button.setVisible(false);
		this.psp_cpss_discard_button.setVisible(false);
		this.psp_confirmPSsave_dialog.setVisible(false);
		this.psp_confirmPSsave_dialog.setEnabled(false);
	}

	public void disable_psp_confirmPSTsave_dialog() {
		this.psp_cpsts_progressbar.setEnabled(false);
		this.psp_cpsts_Processing_label.setEnabled(false);
		this.psp_cpsts_progressbar.setVisible(false);
		this.psp_cpsts_Processing_label.setVisible(false);
		this.psp_confirmPSTsave_dialog.setVisible(false);
		this.psp_confirmPSTsave_dialog.setEnabled(false);
		this.psp_cpsts_confirmAll_button.setEnabled(false);
		this.psp_cpsts_discard_button.setEnabled(false);
		this.psp_cpsts_confirmAll_button.setVisible(false);
		this.psp_cpsts_discard_button.setVisible(false);
	}

	public void setPriceSheetPanelCreatePriceSheetDialogComponentsTo(
			boolean flag) {
		this.psp_cps_error_label.setText("");
		this.psp_CreatePriceSheet_dialog.setEnabled(flag);
		this.psp_cps_NameField_field.setEnabled(flag);
		this.psp_cps_selectPST_combobox.setEnabled(flag);
		this.psp_cps_Save_button.setEnabled(flag);
		this.psp_cps_usePSForTemplate_checkbox.setEnabled(flag);
		this.psp_cps_selectPS_combobox.setEnabled(false);
		this.psp_cps_ps_name.setEnabled(false);

		this.psp_cps_usePSForTemplate_checkbox.setVisible(flag);
		this.psp_cps_selectPS_combobox.setVisible(flag);
		this.psp_cps_ps_name.setVisible(flag);
		this.psp_CreatePriceSheet_dialog.setVisible(flag);
		this.psp_cps_NameField_field.setVisible(flag);
		this.psp_cps_selectPST_combobox.setVisible(flag);
		this.psp_cps_Save_button.setVisible(flag);
		this.psp_cps_dialogname_label.setVisible(flag);
		this.psp_cps_name_label.setVisible(false);
		this.psp_cps_pst_name.setVisible(false);

	}

	public void setPriceSheetPanelCreatePriceSheetTemplateDialogComponentsTo(
			boolean flag) {
		this.psp_CreateTemplate_dialog.setEnabled(flag);

		this.psp_ct_Save_button.setEnabled(flag);
		this.psp_ct_NameField_field.setEditable(flag);

		this.psp_CreateTemplate_dialog.setVisible(flag);
		this.psp_ct_Save_button.setVisible(flag);
		this.psp_ct_NameField_field.setVisible(flag);
		this.psp_ct_dialogname_label.setVisible(flag);
		this.psp_ct_error_label.setVisible(flag);
		this.psp_ct_name_label.setVisible(flag);

	}

	public void setFoundCustomersDialogEnabledParamenterTo(boolean flag) {
		this.psp_foundCustomers_dialog.setVisible(flag);
		this.psp_fc_close_button.setVisible(flag);
		this.psp_fc_customerNames_textArea.setVisible(flag);
		this.psp_fc_serviceText2_label.setVisible(flag);
		this.psp_fc_serviceText_label.setVisible(flag);
		this.psp_fc_tempalteInfo_label.setVisible(flag);

		this.psp_fc_tempalteInfo_label.setText("");
		this.psp_fc_customerNames_textArea.setText("");
		this.psp_fc_close_button.setEnabled(flag);

	}

	public void reloadPSP_comboboxes() {
		//////////////
		//initialize//
		//////////////
		boolean psp_cps_PST = false;
		boolean psp_PST = false;
		boolean psp_PS = false;

		ArrayList<Pricesheets> PSsList = MEDIATOR.getPriceSheets();
		ArrayList<Pricesheets> PSTsList = MEDIATOR.getPriceSheetTemplates();

		//////////////////////////////////////
		//clear the comboboxes and set flags//
		//////////////////////////////////////
		MEDIATOR.reloadDB();
		if (this.psp_cps_selectPST_combobox.getItemCount() != PSTsList.size()) {
			System.out.println("CPS_PST::ItemCount = "
					+ psp_cps_selectPST_combobox.getItemCount()
					+ " ;ListSize = " + PSTsList.size());//debug

			psp_cps_PST = true;
			this.psp_cps_selectPST_combobox.removeAllItems();
		}

		if (this.psp_priceSheetTemplate_combobox.getItemCount() != PSTsList
				.size()) {
			psp_PST = true;
			this.psp_priceSheetTemplate_combobox.removeAllItems();
		}

		if (this.psp_priceSheet_combobox.getItemCount() != PSsList.size()) {
			psp_PS = true;
			this.psp_priceSheet_combobox.removeAllItems();
		}

		///////////////////////		
		//and refill it again//
		///////////////////////
		if (psp_PST || psp_cps_PST) {

			if (psp_PST) {
				this.psp_priceSheetTemplate_combobox.addItem(null);
				for (int i = 0; i < PSTsList.size(); i++) {

					this.psp_priceSheetTemplate_combobox.addItem(PSTsList
							.get(i).getPriceSheetName());
				}

			}

			if (psp_cps_PST) {
				for (int i = 0; i < PSTsList.size(); i++) {

					this.psp_cps_selectPST_combobox.addItem(PSTsList.get(i)
							.getPriceSheetName());
				}
			}
		}

		if (psp_PS) {
			this.psp_priceSheet_combobox.addItem(null);
			for (int i = 0; i < PSsList.size(); i++) {
				this.psp_priceSheet_combobox.addItem(PSsList.get(i)
						.getPriceSheetName());
			}
		}
	}

	public void reloadPriceSheetCombobox() {
		this.psp_priceSheet_combobox.removeAllItems();

		ArrayList<Pricesheets> PSsList = MEDIATOR.getPriceSheets();
		this.psp_priceSheet_combobox.addItem(null);
		for (int i = 0; i < PSsList.size(); i++) {
			this.psp_priceSheet_combobox.addItem(PSsList.get(i)
					.getPriceSheetName());
		}
	}

	public void loadPriceSheetComboboxWithChildrenOf(int PSTid) {
		this.psp_priceSheet_combobox.removeAllItems();

		Pricesheets[] children = MEDIATOR.getAllChildrenOfPST(PSTid);

		this.psp_priceSheet_combobox.addItem(null);
		for (int i = 0; i < children.length; i++) {
			System.out.println("da executioner");
			this.psp_priceSheet_combobox.addItem(children[i]
					.getPriceSheetName());
		}
	}

	public void loadCPSPriceSheetComboboxWithChildrenOf(int PSTid) {
		this.psp_cps_selectPS_combobox.removeAllItems();

		Pricesheets[] children = MEDIATOR.getAllChildrenOfPST(PSTid);

		this.psp_cps_selectPS_combobox.addItem(null);
		for (int i = 0; i < children.length; i++) {
			System.out.println("da executioner");
			this.psp_cps_selectPS_combobox.addItem(children[i]
					.getPriceSheetName());
		}
	}

	public void displayPriceSheetItemListTable(Pricesheetitems[] PSitems) {
		clearPriceSheetItemListTable();

		if (PSitems == null) {
			System.out
					.println("ERROR!!!!!!!!!!! in psp_priceSheetTemplate_comboboxActionPerformed");
		}

		//		System.out.println("PSitems: " + PSitems+ " length = "+ PSitems.length);
		//		for (int i = 1; i < PSitems.length;i++)
		//		{
		//			System.out.println(i);
		//			System.out.println(PSitems[i].toString());
		//		}

		for (int row = 0; row < PSitems.length; row++) {
			Items _itm = MEDIATOR.getItem(PSitems[row].getItemID());

			this.psp_itemList_table.setValueAt(_itm.getItemID(), row,
					this.PS_ID_COLUMN);
			this.psp_itemList_table.setValueAt(_itm.getItemDescription(), row,
					this.PS_DESCRIPTION_COLUMN);
			this.psp_itemList_table.setValueAt(_itm.getItemName(), row,
					this.PS_NAME_COLUMN);
			this.psp_itemList_table.setValueAt(_itm.getUnitName(), row,
					this.PS_UNIT1_COLUMN);
			this.psp_itemList_table.setValueAt(_itm.getOtherUnitName(), row,
					this.PS_UNIT2_COLUMN);
			this.psp_itemList_table.setValueAt(
					PSitems[row].getOtherUnitPrice(), row,
					this.PS_UNIT1PRICE_COLUMN);
			this.psp_itemList_table.setValueAt(
					PSitems[row].getOtherUnitPrice(), row,
					this.PS_UNIT2PRICE_COLUMN);

		}

	}

	public void displayPriceSheetItemListTableWithFormatting(
			ArrayList<Pricesheetitems> PSitems) {
		clearPriceSheetItemListTable();

		Pricesheetitems[] tmp = this.MEDIATOR.getPriceSheetItems(this.MEDIATOR
				.getPSid((String) this.psp_priceSheet_combobox
						.getSelectedItem()));

		ArrayList<Pricesheetitems> originals = new ArrayList<Pricesheetitems>();
		for (int i = 0; i < tmp.length; i++) {
			originals.add(tmp[i]);
		}

		//		if (PSitems == null) {
		//			System.out
		//					.println("ERROR!!!!!!!!!!! in psp_priceSheetTemplate_comboboxActionPerformed");
		//		}

		int row = 0;
		for (Pricesheetitems _psitm : PSitems) {
			Items _itm = MEDIATOR.getItem(_psitm.getItemID());

			String marker = "";
			for (int i = 0; i < originals.size(); i++) {
				if (originals.get(i).getItemID() == _itm.getItemID()) {
					marker = MARKER;
				}
			}

			this.psp_itemList_table.setValueAt(_itm.getItemID(), row,
					this.PS_ID_COLUMN);
			this.psp_itemList_table.setValueAt(_itm.getItemDescription(), row,
					this.PS_DESCRIPTION_COLUMN);
			this.psp_itemList_table.setValueAt(marker + _itm.getItemName(),
					row, this.PS_NAME_COLUMN);
			this.psp_itemList_table.setValueAt(_itm.getUnitName(), row,
					this.PS_UNIT1_COLUMN);
			this.psp_itemList_table.setValueAt(_itm.getOtherUnitName(), row,
					this.PS_UNIT2_COLUMN);
			this.psp_itemList_table.setValueAt(_psitm.getOtherUnitPrice(), row,
					this.PS_UNIT1PRICE_COLUMN);
			this.psp_itemList_table.setValueAt(_psitm.getOtherUnitPrice(), row,
					this.PS_UNIT2PRICE_COLUMN);
			row++;

		}

	}

	public void clearPriceSheetItemListTable() {
		int row = 0;
		while (this.psp_itemList_table.getValueAt(row, this.PS_ID_COLUMN) != null) {
			this.psp_itemList_table.setValueAt(null, row, this.PS_ID_COLUMN);
			this.psp_itemList_table.setValueAt(null, row,
					this.PS_DESCRIPTION_COLUMN);
			this.psp_itemList_table.setValueAt(null, row, this.PS_NAME_COLUMN);
			this.psp_itemList_table.setValueAt(null, row, this.PS_UNIT1_COLUMN);
			this.psp_itemList_table.setValueAt(null, row, this.PS_UNIT2_COLUMN);
			this.psp_itemList_table.setValueAt(null, row,
					this.PS_UNIT1PRICE_COLUMN);
			this.psp_itemList_table.setValueAt(null, row,
					this.PS_UNIT2PRICE_COLUMN);
			row++;
		}
	}

	public boolean noInputErrorsInTable() {

		String errors = "";
		boolean found_no_errors = true;
		int row = 0;
		while (this.psp_itemList_table.getValueAt(row, this.PS_ID_COLUMN) != null) {
			//TODO: will break in next version
			float price1 = (Float) this.psp_itemList_table.getValueAt(row,
					PS_UNIT1PRICE_COLUMN);
			float price2 = (Float) this.psp_itemList_table.getValueAt(row,
					PS_UNIT2PRICE_COLUMN);

			if (price1 <= 0.0 || price2 <= 0.0 || price1 > 20.0
					|| price2 > 20.0) {
				found_no_errors = false;
				String name = (String) this.psp_itemList_table.getValueAt(row,
						PS_NAME_COLUMN);
				if (name.startsWith(MARKER)) {
					name = name.substring(MARKER.length());
				}
				errors = errors.concat(name + " ; <br /> ");
			}

			row++;
		}

		if (!found_no_errors) {

			notificationDialog
					.displayNotification("The price changes set for the following items are either a sale of more than 100% off or a price increase by more than 2000% <br /> :"
							+ errors
							+ " <br />  you will not be able to save untill the corrections are made");
		}

		return found_no_errors;
	}

	public void findChangesInTable(Pricesheetitems[] PS,
			ArrayList<Pricesheetitems> completePS) {

		////////////////////////////
		//initial component enable//
		////////////////////////////

		this.psp_confirmPSsave_dialog.setVisible(true);
		this.psp_confirmPSsave_dialog.setEnabled(true);
		this.psp_cpss_progressbar.setEnabled(true);
		this.psp_cpss_Processing_label.setEnabled(true);
		this.psp_cpss_progressbar.setVisible(true);
		this.psp_cpss_Processing_label.setVisible(true);

		this.psp_cpss_confirmAll_button.setVisible(false);
		this.psp_cpss_confirmModifications_button.setVisible(false);
		this.psp_cpss_confirmAdditions_button.setVisible(false);
		this.psp_cpss_confirmAll_button.setEnabled(false);
		this.psp_cpss_confirmModifications_button.setEnabled(false);
		this.psp_cpss_confirmAdditions_button.setEnabled(false);

		this.psp_cpss_discard_button.setText("Discard");
		this.psp_cpss_changes_label.setText("");

		modQueue.clear();
		addQueue.clear();

		int PriceSheetID = PS[0].getPriceSheetID();

		this.psp_cpss_progressbar
				.setMaximum((completePS.size() + PS.length) * 2 + 2);
		this.psp_cpss_progressbar.setMaximum(0);

		int progressbar_counter = 0;
		this.psp_cpss_progressbar.setValue(progressbar_counter);

		String changesString = "";
		String addedString = "";

		///////////////////////////
		// take care of the maps //
		///////////////////////////

		HashMap<Integer, Pricesheetitems> _map = new HashMap<Integer, Pricesheetitems>(
				PS.length);
		for (int i = 0; i < PS.length; i++) {
			_map.put(PS[i].getItemID(), PS[i]);
			progressbar_counter = progressbar_counter++;
			this.psp_cpsts_progressbar.setValue(progressbar_counter);
		}

		HashMap<Integer, Pricesheetitems> _compelteMap = new HashMap<Integer, Pricesheetitems>(
				completePS.size());
		for (int i = 0; i < completePS.size(); i++) {
			_compelteMap.put(completePS.get(i).getItemID(), completePS.get(i));
			progressbar_counter = progressbar_counter++;
			this.psp_cpsts_progressbar.setValue(progressbar_counter);
		}

		///////////////////////
		// parse for changes //
		///////////////////////

		int row = 0;
		while (this.psp_itemList_table.getValueAt(row, this.PS_ID_COLUMN) != null) {
			//TODO: will break in next version
			float price1 = (Float) this.psp_itemList_table.getValueAt(row,
					PS_UNIT1PRICE_COLUMN);
			float price2 = (Float) this.psp_itemList_table.getValueAt(row,
					PS_UNIT2PRICE_COLUMN);
			int item_id = (Integer) this.psp_itemList_table.getValueAt(row,
					this.PS_ID_COLUMN);

			Pricesheetitems _psi = _map.get(item_id);
			if (_psi != null) {
				System.out.println("Item found on map");
				if (_psi.getPrice() != price1
						|| _psi.getOtherUnitPrice() != price2) {
					Pricesheetitems _psiX = new Pricesheetitems();
					_psiX.setItemID(_psi.getItemID());
					_psiX.setPriceSheetID(_psi.getPriceSheetID());
					_psiX.setPriceSheetItemID(_psi.getPriceSheetItemID());
					_psiX.setPrice(price1);
					_psiX.setOtherUnitPrice(price2);
					modQueue.add(_psiX);
					System.out.println(modQueue.toString());
					String name = (String) this.psp_itemList_table.getValueAt(
							row, this.PS_NAME_COLUMN);
					if (name.startsWith(MARKER)) {
						name = name.substring(MARKER.length());
					}
					changesString = changesString.concat(name + " ; \n ");
					System.out.println("changesString: " + changesString);
				}
			} else {
				_psi = _compelteMap.get(item_id);
				if (_psi != null) {
					System.out.println("Item found on complete map");
					System.out.println("NAME: "
							+ (String) this.psp_itemList_table.getValueAt(row,
									this.PS_NAME_COLUMN));
					System.out.println("Price1 in _psi: " + _psi.getPrice()
							+ " and on screen: " + price1);
					System.out.println("Price2 in _psi: " + _psi.getPrice()
							+ " and on screen: " + price2);
					if (_psi.getPrice() != price1
							|| _psi.getOtherUnitPrice() != price2) {
						Pricesheetitems _psiX = new Pricesheetitems();
						_psiX.setItemID(_psi.getItemID());
						_psiX.setPriceSheetID(PriceSheetID);
						//_psiX.setPriceSheetID(_psi.getPriceSheetID()); <= not quite correct
						//_psiX.setPriceSheetItemID(_psi.getPriceSheetItemID()); <- autoincrement:) 
						_psiX.setPrice(price1);
						_psiX.setOtherUnitPrice(price2);
						addQueue.add(_psiX);
						System.out.println(addQueue.toString());
						addedString = addedString
								.concat((String) this.psp_itemList_table
										.getValueAt(row, this.PS_NAME_COLUMN)
										+ " ; \n ");
						System.out.println("AddedString: " + addedString);

					}
				}
			}

			progressbar_counter = progressbar_counter++;
			this.psp_cpsts_progressbar.setValue(progressbar_counter);
			row++;
		}

		/////////////////////
		// display changes //
		/////////////////////

		this.psp_cpss_progressbar.setVisible(false);
		this.psp_cpss_Processing_label.setVisible(false);
		this.psp_cpss_discard_button.setVisible(true);
		this.psp_cpss_discard_button.setEnabled(true);
		this.psp_cpss_changes_label.setVisible(true);
		this.psp_cpss_changes_label.setEnabled(true);

		String alert_text = "";

		if (modQueue.size() != 0) {
			this.psp_cpss_confirmModifications_button.setEnabled(true);
			this.psp_cpss_confirmModifications_button.setVisible(true);
			alert_text = "\nThe following changes were found:\n"
					+ changesString;
		}
		if (addQueue.size() != 0) {
			this.psp_cpss_confirmAdditions_button.setEnabled(true);
			this.psp_cpss_confirmAdditions_button.setVisible(true);
			alert_text = "\nThe following items were added:\n" + addedString;
		}
		if (modQueue.size() != 0 && addQueue.size() != 0) {
			this.psp_cpss_confirmAll_button.setEnabled(true);
			this.psp_cpss_confirmAll_button.setVisible(true);
			alert_text = "\nThe following changes were found:\n"
					+ changesString + "\nThe following items were added:\n"
					+ addedString;

		}
		if (modQueue.size() == 0 && addQueue.size() == 0) {
			this.psp_cpss_discard_button.setText("Exit");
			alert_text = "No changes were found";
		}

		this.psp_cpss_changes_label.setText(alert_text);

	}

	public void findChangesInTable(Pricesheetitems[] PST) {

		////////////////////////////
		//initial component enable//
		////////////////////////////

		this.psp_confirmPSTsave_dialog.setVisible(true);
		this.psp_confirmPSTsave_dialog.setEnabled(true);
		this.psp_cpsts_progressbar.setEnabled(true);
		this.psp_cpsts_Processing_label.setEnabled(true);
		this.psp_cpsts_progressbar.setVisible(true);
		this.psp_cpsts_Processing_label.setVisible(true);

		this.psp_cpsts_discard_button.setText("Discard");
		this.psp_cpsts_changes_label.setText("");

		modQueue.clear();

		this.psp_cpsts_progressbar.setMaximum((PST.length) * 2 + 2);
		this.psp_cpsts_progressbar.setMaximum(0);

		int progressbar_counter = 0;
		this.psp_cpsts_progressbar.setValue(progressbar_counter);

		String changesString = "";
		//////////////////////////
		// take care of the map //
		//////////////////////////
		HashMap<Integer, Pricesheetitems> _map = new HashMap<Integer, Pricesheetitems>(
				PST.length);
		for (int i = 0; i < PST.length; i++) {
			_map.put(PST[i].getItemID(), PST[i]);
			progressbar_counter = progressbar_counter++;
			this.psp_cpsts_progressbar.setValue(progressbar_counter);
		}

		///////////////////////
		// parse for changes //
		///////////////////////

		int row = 0;
		while (this.psp_itemList_table.getValueAt(row, this.PS_ID_COLUMN) != null) {
			//TODO: will break in next version
			float price1 = (Float) this.psp_itemList_table.getValueAt(row,
					PS_UNIT1PRICE_COLUMN);
			float price2 = (Float) this.psp_itemList_table.getValueAt(row,
					PS_UNIT2PRICE_COLUMN);
			int item_id = (Integer) this.psp_itemList_table.getValueAt(row,
					this.PS_ID_COLUMN);

			Pricesheetitems _psi = _map.get(item_id);
			if (_psi != null) {
				if (_psi.getPrice() != price1
						|| _psi.getOtherUnitPrice() != price2) {
					Pricesheetitems _psiX = new Pricesheetitems();
					_psiX.setItemID(_psi.getItemID());
					_psiX.setPriceSheetID(_psi.getPriceSheetID());
					_psiX.setPriceSheetItemID(_psi.getPriceSheetItemID());
					_psiX.setPrice(price1);
					_psiX.setOtherUnitPrice(price2);
					modQueue.add(_psiX);

					changesString = changesString
							.concat((String) this.psp_itemList_table
									.getValueAt(row, this.PS_NAME_COLUMN)
									+ " ; \n");
				}
			}

			progressbar_counter = progressbar_counter++;
			this.psp_cpsts_progressbar.setValue(progressbar_counter);
			row++;
		}

		/////////////////////
		// display changes //
		/////////////////////

		this.psp_cpsts_progressbar.setVisible(false);
		this.psp_cpsts_Processing_label.setVisible(false);
		this.psp_cpsts_discard_button.setVisible(true);
		this.psp_cpsts_discard_button.setEnabled(true);
		this.psp_cpsts_changes_label.setVisible(true);
		this.psp_cpsts_changes_label.setEnabled(true);
		this.psp_cpsts_confirmAll_button.setEnabled(false);
		this.psp_cpsts_confirmAll_button.setVisible(false);

		if (modQueue.size() != 0) {
			this.psp_cpsts_confirmAll_button.setEnabled(true);
			this.psp_cpsts_confirmAll_button.setVisible(true);
			this.psp_cpsts_changes_label
					.setText("The following changes were found:\n"
							+ changesString);
		} else {
			this.psp_cpsts_discard_button.setText("Exit");

			this.psp_cpsts_changes_label.setText("No changes were found");

		}

	}

	private String TurnCustomerListIntoHTML(Customers[] _cust) {
		String output = " <ul> ";
		for (int i = 0; i < _cust.length; i++) {
			output += " <li> " + _cust[i].getCustomerName() + " : "
					+ _cust[i].getCustomerID() + " </li> ";
		}
		output += " </ul> ";
		return output;
	}

	private String TurnPriceSheetListIntoHTML(Pricesheets[] _ps) {

		String output = " <ul> ";
		for (int i = 0; i < _ps.length; i++) {
			output += " <li> " + _ps[i].getPriceSheetName() + " : "
					+ _ps[i].getPriceSheetID() + " </li> ";
		}
		output += " </ul> ";
		return output;
	}

}